package cn.bluethink.eguan.model.okrtask;

import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonInclude;

import cn.bluethink.eguan.model.core.EgOType;
import cn.bluethink.eguan.model.core.EgTask;
import cn.bluethink.eguan.model.core.EgUser;
import cn.bluethink.eguan.utils.OkrTaskUtil;

public class EgTarget extends EgTask {
	
	/**
	 * 任务计时类型（日、周、月、季度、年）
	 */
	private Integer timing;
	
	/**
     * 目标标签，用于显示的标记，不需要持久化
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
	private String label;
	
	/**
	 * 如果该工作任务为目标，该字段为当前目标的前置目标
	 */
	@JsonInclude(JsonInclude.Include.NON_NULL)
	private EgOkrTask parent;

	/**
	 * 目标颜色，如果有目标标签，该项有对应显示
	 */
	private Integer color;
	
	/**
	 * 任务进展百分比
	 */
	@JsonInclude(JsonInclude.Include.NON_NULL)
	private String targetProgress;

	/**
	 * 任务参与者列表
	 */
	@JsonInclude(JsonInclude.Include.NON_NULL)
	private List<EgUser> userList = null;

	/**
	 * @since 1.0.0
	 * @roseuid 5B6D4F61009E
	 */
	public EgTarget() {

	}
	
	public EgTarget(Long tid, String name, String content) {
		super(tid, name, content, new EgOType(EgOType.OKR_TASK, null));
	}
	
	/**
     * 计算标签label
     * 
     * @param bmonth
     * @throws Exception
     */
    public void calculateLabel(Integer bmonth) {
        Date etime = getEtime();
        if (timing == null || etime == null) {
            return;
        }
        OkrTaskUtil util = new OkrTaskUtil();
        label = util.label(timing, etime, bmonth);
    }
	
	public Integer getTiming() {
		return timing;
	}

	public void setTiming(Integer timing) {
		this.timing = timing;
	}

	public EgOkrTask getParent() {
		return parent;
	}

	public void setParent(EgOkrTask parent) {
		this.parent = parent;
	}

	public String getTargetProgress() {
		return targetProgress;
	}

	public void setTargetProgress(String targetProgress) {
		this.targetProgress = targetProgress;
	}

	public List<EgUser> getUserList() {
		return userList;
	}

	public void setUserList(List<EgUser> userList) {
		this.userList = userList;
	}

    public Integer getColor() {
        return color;
    }

    public void setColor(Integer color) {
        this.color = color;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }
	
}
